#include "widget.h"
#include "ui_widget.h"
#include <QMouseEvent>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    timeId = startTimer(1000);
    ui->lcdNumber->display(10);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::wheelEvent(QWheelEvent *event)
{
    qDebug()<<event->delta();
}

void Widget::keyPressEvent(QKeyEvent *event)
{
    if(event->modifiers()==Qt::ControlModifier)
        qDebug()<<event->key();
}

void Widget::timerEvent(QTimerEvent *event)
{
    if(timeId == event->timerId())
    {
        int value = ui->lcdNumber->value();
        if(value<=0)
        {
            this->killTimer(timeId);
            return;
        }
        value-=1;
        ui->lcdNumber->display(value);
    }
}

